package com.hliushi.demo.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;


/**
 * CstCustomer
 *
 * @author auto generated
 * @date 2021-07-17 16:26:31
 */
@Data
@Entity
@Table(name = "cst_customer")
@ApiModel(value = "CstCustomer")
public class CstCustomer implements Serializable {

    private static final long serialVersionUID = -8857789591340213160L;
    /**
     * 客户编号(主键)
     * nullable : false
     * default  : null
     */
    @Id
    @ApiModelProperty(value = "客户编号(主键)")
    @Column(name = "cust_id", nullable = true, length = 32)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long custId;

    /**
     * 客户名称(公司名称)
     * nullable : false
     * default  : null
     */
    @ApiModelProperty(value = "客户名称(公司名称)")
    @Column(name = "cust_name", nullable = true, length = 32)
    private String custName;

    /**
     * 客户信息来源
     * nullable : true
     * default  : null
     */
    @ApiModelProperty(value = "客户信息来源")
    @Column(name = "cust_source", nullable = true, length = 32)
    private String custSource;

    /**
     * 客户所属行业
     * nullable : true
     * default  : null
     */
    @ApiModelProperty(value = "客户所属行业")
    @Column(name = "cust_industry", nullable = true, length = 32)
    private String custIndustry;

    /**
     * 客户级别
     * nullable : true
     * default  : null
     */
    @ApiModelProperty(value = "客户级别")
    @Column(name = "cust_level", nullable = true, length = 32)
    private String custLevel;

    /**
     * 客户联系地址
     * nullable : true
     * default  : null
     */
    @ApiModelProperty(value = "客户联系地址")
    @Column(name = "cust_address", nullable = true, length = 128)
    private String custAddress;

    /**
     * 客户联系电话
     * nullable : true
     * default  : null
     */
    @ApiModelProperty(value = "客户联系电话")
    @Column(name = "cust_phone", nullable = true, length = 64)
    private String custPhone;


    /**
     * 配置客户和联系人之间的关系 (一对多关系)
     * #
     * 使用注解的形式配置多表关系
     * .	1.声明关系
     * .		@OneToMany: 配置一对多关系
     * .			targetEntity: 对方对象的字节码对象
     * .	2.配置外键(中间表)
     * .		@JoinColumn: 配置外键
     * .			name: 从表外键字段名称
     * .			referencedColumnName: 参照的主表的主键字段名称
     * #
     * # 在客户实体类上()
     */
    @JsonBackReference // 在生成JSON是排除这一属性
    @JoinColumn(name = "lkm_cust_id", referencedColumnName = "cust_id")
    @OneToMany(targetEntity = CstLinkman.class, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    // @OneToMany(targetEntity = CstLinkman.class)
    private Set<CstLinkman> linkmanSet = new HashSet<>();

}
